// Copyright 2009 Google Inc. All Rights Reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
//     * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
//     * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following disclaimer
// in the documentation and/or other materials provided with the
// distribution.
//     * Neither the name of Google Inc. nor the names of its
// contributors may be used to endorse or promote products derived from
// this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

// This sample shows how to use Google Test listener API to implement
// a primitive leak checker.

#include <stdio.h>
#include <stdlib.h>
#include <iostream>

#include "gtest/gtest.h"
#include "../ast_to_json.hpp"
#include "expression_golden_sample.hpp"

using ::testing::EmptyTestEventListener;
using ::testing::InitGoogleTest;
using ::testing::Test;
using ::testing::TestEventListeners;
using ::testing::TestInfo;
using ::testing::TestPartResult;
using ::testing::UnitTest;

namespace cyclone::parser
{
  static cyclone::parser::AstToJson parser;
  TEST(ExpressionTest, Identifier) { EXPECT_EQ(parser.parse(ExpressionGoldenSample::expresion(EstreeExpression::Identifier)), ExpressionGoldenSample::ast(EstreeExpression::Identifier)); }
  TEST(ExpressionTest, BinaryExpression) { EXPECT_EQ(parser.parse(ExpressionGoldenSample::expresion(EstreeExpression::BinaryExpression)), ExpressionGoldenSample::ast(EstreeExpression::BinaryExpression)); }
  TEST(ExpressionTest, ThisExpression) { EXPECT_EQ(parser.parse(ExpressionGoldenSample::expresion(EstreeExpression::ThisExpression)), ExpressionGoldenSample::ast(EstreeExpression::ThisExpression)); }
  TEST(ExpressionTest, ArrayExpression) { EXPECT_EQ(parser.parse(ExpressionGoldenSample::expresion(EstreeExpression::ArrayExpression)), ExpressionGoldenSample::ast(EstreeExpression::ArrayExpression)); }
  TEST(ExpressionTest, ObjectExpression) { EXPECT_EQ(parser.parse(ExpressionGoldenSample::expresion(EstreeExpression::ObjectExpression)), ExpressionGoldenSample::ast(EstreeExpression::ObjectExpression)); }
  TEST(ExpressionTest, FunctionExpression) { EXPECT_EQ(parser.parse(ExpressionGoldenSample::expresion(EstreeExpression::FunctionExpression)), ExpressionGoldenSample::ast(EstreeExpression::FunctionExpression)); }
  TEST(ExpressionTest, ArrowFunctionExpression) { EXPECT_EQ(parser.parse(ExpressionGoldenSample::expresion(EstreeExpression::ArrowFunctionExpression)), ExpressionGoldenSample::ast(EstreeExpression::ArrowFunctionExpression)); }
  TEST(ExpressionTest, YieldExpression) { EXPECT_EQ(parser.parse(ExpressionGoldenSample::expresion(EstreeExpression::YieldExpression)), ExpressionGoldenSample::ast(EstreeExpression::YieldExpression)); }
  TEST(ExpressionTest, Literal) { EXPECT_EQ(parser.parse(ExpressionGoldenSample::expresion(EstreeExpression::Literal)), ExpressionGoldenSample::ast(EstreeExpression::Literal)); }
  TEST(ExpressionTest, UnaryExpression) { EXPECT_EQ(parser.parse(ExpressionGoldenSample::expresion(EstreeExpression::UnaryExpression)), ExpressionGoldenSample::ast(EstreeExpression::UnaryExpression)); }
  TEST(ExpressionTest, UpdateExpression) { EXPECT_EQ(parser.parse(ExpressionGoldenSample::expresion(EstreeExpression::UpdateExpression)), ExpressionGoldenSample::ast(EstreeExpression::UpdateExpression)); }
  TEST(ExpressionTest, AssignmentExpression) { EXPECT_EQ(parser.parse(ExpressionGoldenSample::expresion(EstreeExpression::AssignmentExpression)), ExpressionGoldenSample::ast(EstreeExpression::AssignmentExpression)); }
  TEST(ExpressionTest, LogicalExpression) { EXPECT_EQ(parser.parse(ExpressionGoldenSample::expresion(EstreeExpression::LogicalExpression)), ExpressionGoldenSample::ast(EstreeExpression::LogicalExpression)); }
  TEST(ExpressionTest, MemberExpression) { EXPECT_EQ(parser.parse(ExpressionGoldenSample::expresion(EstreeExpression::MemberExpression)), ExpressionGoldenSample::ast(EstreeExpression::MemberExpression)); }
  TEST(ExpressionTest, ConditionalExpression) { EXPECT_EQ(parser.parse(ExpressionGoldenSample::expresion(EstreeExpression::ConditionalExpression)), ExpressionGoldenSample::ast(EstreeExpression::ConditionalExpression)); }
  TEST(ExpressionTest, CallExpression) { EXPECT_EQ(parser.parse(ExpressionGoldenSample::expresion(EstreeExpression::CallExpression)), ExpressionGoldenSample::ast(EstreeExpression::CallExpression)); }
  TEST(ExpressionTest, NewExpression) { EXPECT_EQ(parser.parse(ExpressionGoldenSample::expresion(EstreeExpression::NewExpression)), ExpressionGoldenSample::ast(EstreeExpression::NewExpression)); }
  TEST(ExpressionTest, SequenceExpression) { EXPECT_EQ(parser.parse(ExpressionGoldenSample::expresion(EstreeExpression::SequenceExpression)), ExpressionGoldenSample::ast(EstreeExpression::SequenceExpression)); }
  TEST(ExpressionTest, TemplateLiteral) { EXPECT_EQ(parser.parse(ExpressionGoldenSample::expresion(EstreeExpression::TemplateLiteral)), ExpressionGoldenSample::ast(EstreeExpression::TemplateLiteral)); }
  TEST(ExpressionTest, TaggedTemplateExpression) { EXPECT_EQ(parser.parse(ExpressionGoldenSample::expresion(EstreeExpression::TaggedTemplateExpression)), ExpressionGoldenSample::ast(EstreeExpression::TaggedTemplateExpression)); }
  // TEST(ExpressionTest, ClassExpression) { EXPECT_EQ(parser.parse(ExpressionGoldenSample::expresion(EstreeExpression::ClassExpression)), ExpressionGoldenSample::ast(EstreeExpression::ClassExpression)); }
  TEST(ExpressionTest, MetaProperty) { EXPECT_EQ(parser.parse(ExpressionGoldenSample::expresion(EstreeExpression::MetaProperty)), ExpressionGoldenSample::ast(EstreeExpression::MetaProperty)); }
  TEST(ExpressionTest, AwaitExpression) { EXPECT_EQ(parser.parse(ExpressionGoldenSample::expresion(EstreeExpression::AwaitExpression)), ExpressionGoldenSample::ast(EstreeExpression::AwaitExpression)); }
  TEST(ExpressionTest, ImportExpression) { EXPECT_EQ(parser.parse(ExpressionGoldenSample::expresion(EstreeExpression::ImportExpression)), ExpressionGoldenSample::ast(EstreeExpression::ImportExpression)); }
  TEST(ExpressionTest, ChainExpression) { EXPECT_EQ(parser.parse(ExpressionGoldenSample::expresion(EstreeExpression::ChainExpression)), ExpressionGoldenSample::ast(EstreeExpression::ChainExpression)); }

} // namespace cyclone::parser

int main(int argc, char **argv)
{
  InitGoogleTest(&argc, argv);
  return RUN_ALL_TESTS();
}
